
<#include "header.ftl">
<link rel="stylesheet" type="text/css" href="${Domain}common/address-master/dist/amazeui.address.css" />
<script src="${Domain}common/address-master/dist/iscroll.min.js" type="text/javascript" charset="utf-8"></script>
<script src="${Domain}common/address-master/dist/address.js" type="text/javascript" charset="utf-8"></script>
  <!-- 内容区域 -->
<div class="tpl-content-wrapper">
 <div class="container-fluid am-cf">
                <div class="row">
                    <div class="am-u-sm-12 am-u-md-12 am-u-lg-9">
                        <ol class="am-breadcrumb">
						  <li><a href="${Domain}my" class="am-icon-home">首页</a></li>						
						  <li ><a href="${Domain}my/main/list" >实体</a></li>
						  <li class="am-active">添加实体</li>
						</ol>
                    </div>
                  	<#include "../common/return.ftl">
                </div>
  </div>
       <div class="row-content am-cf">
          
       
                <div class="row">
  
                    <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                        <div class="widget am-cf">
                            <div class="widget-head am-cf">
                                <div class="widget-title  am-cf">实体添加</div>
                            </div>
                            <div class="widget-body  am-fr">     
                             <form class="am-form tpl-form-line-form"  method="post" action="${Domain}api/main/add" id="main-add">
                                   <input type="hidden" id="id" name="id" value="">
									
                                    <div class="am-form-group">
                                        <label  class="am-u-sm-3 am-u-md-3  am-form-label">实体名称 </label>
                                        <div class="am-u-sm-8 am-u-md-6">
                                            <input type="text" class="tpl-form-input" id="main-name" placeholder="请输入名称" name="name" value="" required/>
                                        </div>
                                        <label  class="am-u-sm-1 am-u-md-3"></label>
                                    </div>
                                     <div class="am-form-group">
                                        <label  class="am-u-sm-3 am-u-md-3 am-form-label">实体类型</label>
                                        <div class="am-u-sm-8 am-u-md-6 am-form-group tpl-table-list-select">
                                          <select data-am-selected="{ btnSize: 'sm'}" name="type" id="type"  >
										<option value="0"  >私有云</option> 
										<#list list as item>
										 <option value="${item.id}"  >${item.name}</option>
										 </#list> 	
										 <option value="-1"  >未通过</option>		          
										 </select>
										
                                        </div>
                                        <label  class="am-u-sm-1 am-u-md-3"></label>
                                    </div>
									 <div class="am-form-group">
                                        <label  class="am-u-sm-3 am-u-md-3 am-form-label">联系人员 </label>
                                        <div class="am-u-sm-8 am-u-md-6">
                                            <input type="text" class="tpl-form-input" id="main-contacts" placeholder="请输入联系人姓名" name="contacts" value="" required/>
                                        </div>
                                        <label  class="am-u-sm-1 am-u-md-3"></label>
                                    </div>
                                     <div class="am-form-group">
                                        <label  class="am-u-sm-3 am-u-md-3 am-form-label">联系电话 </label>
                                        <div class="am-u-sm-8 am-u-md-6">
                                            <input type="tel" class="tpl-form-input"  id="main-telephone" placeholder="请输入联系电话" name="telephone" value="" required/>
                                        </div>
                                          <label  class="am-u-sm-1 am-u-md-3"></label>
                                    </div>
                                    <div class="am-form-group" id="address">
                                     <label  class="am-u-sm-3 am-u-md-3 am-form-label">所在省份 </label>
                                        <div class="am-u-sm-8 am-u-md-6">
                                            <input readonly type="text" name="prov" id="prov" class="am-form-field am-radius" placeholder="请选择地址"  value="${(prov.name)!}" required/>
                                        </div>
										<label  class="am-u-sm-1 am-u-md-3"></label>		
									</div>
                                     <div class="am-form-group">
                                        <label  class="am-u-sm-3 am-u-md-3  am-form-label">联系地址 </label>
                                        <div class="am-u-sm-8 am-u-md-6">
                                            <input type="text" class="tpl-form-input" id="main-address" placeholder="请输入联系地址" name="address" value="" required/>
                                        </div>
                                        <label  class="am-u-sm-1 am-u-md-3"></label>
                                    </div>
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-u-md-3  am-form-label">说明简介</label>
                                        <div class="am-u-sm-8 am-u-md-6">
                                            <textarea class="" rows="3" id="main-description" name="description" placeholder="请输入简介"></textarea>
                                        </div>
                                        <label  class="am-u-sm-1 am-u-md-3"></label>
                                    </div>
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-u-md-3  am-form-label">过期日期 </label>
                                        <div class="am-u-sm-8 am-u-md-6">                                       
										  <input type="text" class="am-form-field" name="expdate" id="expdate" placeholder="过期日期" data-am-datepicker="{format: 'yyyy-mm-dd', viewMode: 'years'}" readonly required/>   
                                        </div>
                                        <label  class="am-u-sm-1 am-u-md-3"></label>
                                    </div>
                                   <div class="am-form-group">
                                        <div class="am-u-sm-6 am-u-sm-push-3">
                                            <button type="submit" id="sub" class="am-btn page-header-button tpl-btn-bg-color-success am-btn-block">确定修改</button>
                                        </div>
                                    </div>
                                  

                                </form>
                            
                            
                            </div>
                        </div>
                    </div>
                    
                    
                    
                </div>
            </div> 
 </div>   





  <script type="text/javascript">
			$(function() {
				document.addEventListener('touchmove', function (e) {
					e.preventDefault();
				}, false);
				
				
				//	配置级联层数
				$("#address").address({
					prov: "${(prov.name)!}",
					scrollToCenter: true,
					selectNumber: 1
				});

			});
</script>
<script type="text/javascript">
  var loading ; 
$(function() {
	
  $('#main-add').validator({
    onValid: function(validity) {   
      $(validity.field).closest('.am-form-group').find('.am-alert').hide();
    },
    onInValid: function(validity) {
   
      var $field = $(validity.field);
      var $group = $field.closest('.am-form-group');
      var $tpl = $group.find('.tpl-form-input');
      var $alert = $group.find('.am-alert');
      // 使用自定义的提示信息 或 插件内置的提示信息
      var msg = $tpl.data('validationMessage') || this.getValidationMessage(validity);
      if (!$alert.length) {
        $alert = $('<div class="am-alert am-alert-danger"></div>').hide().
          insertAfter($tpl);
      }
      $alert.html(msg).show();
    }
  });
});
  
  
   $('#main-add').ajaxForm({
	    beforeSubmit: function(a,f,o) {
	        loading=weui.loading('数据加载中...');
	    },
	    success: function(json) {	    	
	    	if(json.status)
	    	{
	    	  	if(loading) loading.hide();
	    		weui.toast("添加成功"); 
	    		if($("#id").val()=="") 
	    		$("#id").val(json.msg);
	    		$("#sub").text("保存修改");
	    		$('#user-add').attr("action","${Domain}api/main/change");
	    		<#if ask.url??>
	    		location.href="${ask.url}";	
	    		</#if>	
	    			
	    	}else
	    	{	
	    		if(loading) loading.hide();
	    	    weui.alert(json.msg);  		 
	    	}
	    }
	});
	
	



	</script>          
<#include "footer.ftl">